const path = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin")
const { CleanWebpackPlugin } = require('clean-webpack-plugin')

module.exports = {
  entry: "./src/index.js", // 可以使用相对路径
  output: {
    filename: "bundle.js",
    path: path.resolve(__dirname, "../dist") // path不能使用相对路径，__dirname是当前绝对路径
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          "style-loader",
          "css-loader",
        ]
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HtmlWebpackPlugin({
      title: 'production environment'
    })
  ]
}